import instance from '../http';

let baseUrl="/comments/"

export const createComment = (data)=>{
    return instance({
        url:baseUrl,
        data,
        method:"post"
    })
}

export const getComments = (page=0, size=10)=>{
    return instance({
        url:baseUrl+"?page="+page+"&size="+size,
        method:"get"
    })
}

export const deleteComment = (id)=>{
    return instance({
        url:baseUrl+id+"/",
        method:"delete"
    })
}

export const getRoots = (article_id,page=0, size=10, topic_id=null)=>{
    if(page<0) page=0
    let url =baseUrl+"roots/"+"?page="+page+"&size="+size+"&article_id="+article_id
    if(topic_id) url+= ("&topic_id="+topic_id)
    return instance({
        url,
        method:"get"
    })
}